<template>
	<div class="personal">
		<el-form label-width="100px" ref="editForm" :model="editForm" :rules="rules">
			<el-form-item  label="课程编号" prop="shipinbianhao"><el-input size="small" v-model="editForm.shipinbianhao" auto-complete="off" placeholder="请输入课程编号" style='width:50%' disabled></el-input></el-form-item>
		<el-form-item  label="课程名称" prop="shipinmingcheng"><el-input size="small" v-model="editForm.shipinmingcheng" auto-complete="off" placeholder="请输入课程名称" style='width:50%' disabled></el-input></el-form-item>
		<el-form-item  label="类别" prop="leibie"><el-input size="small" v-model="editForm.leibie" auto-complete="off" placeholder="请输入类别" style='width:50%' disabled></el-input></el-form-item>
		<el-form-item  label='评分' prop="pingfen"><el-select size="small" v-model="editForm.pingfen" placeholder="请选择评分"><el-option selected label="请选择评分" value=""></el-option><el-option label="1" value="1"></el-option><el-option label="2" value="2"></el-option><el-option label="3" value="3"></el-option><el-option label="4" value="4"></el-option><el-option label="5" value="5"></el-option></el-select></el-form-item>
		<el-form-item  label="评语" prop="pingyu"><el-input type="textarea" size="small" v-model="editForm.pingyu" auto-complete="off" placeholder="请输入评语" style='width:100%'></el-input></el-form-item>
		<el-form-item  label="用户名" prop="yonghuming"><el-input size="small" v-model="editForm.yonghuming" auto-complete="off" placeholder="请输入用户名" style='width:50%' disabled></el-input></el-form-item>
		<el-form-item  label="姓名" prop="xingming"><el-input size="small" v-model="editForm.xingming" auto-complete="off" placeholder="请输入姓名" style='width:50%'></el-input></el-form-item>
		
		</el-form>
		<div slot="footer" class="dialog-footer">
			<el-button size="small" type="primary" :loading="loading" class="title" @click="submitForm('editForm')">添加</el-button>
		</div>
	</div>
</template>

<script>
	import {yingpingfankuiEdit, yingpingfankuiSave,yingpingfankuiDetail} from "@/api/yingpingfankui/yingpingfankuiApi";
	import {Session} from "@/utils/storage";
import {yingshishipinDetail,yingshishipinEdit} from "../../api/yingshishipin/yingshishipinApi";
//xiabiaoduan1
export default {
	name: 'personal',
	data() {
		return {
			rules: {
				//yztssssss1
			},
			editForm: {
				avater:'',
				shipinbianhao:'',
				shipinmingcheng:'',
				leibie:'',
				
			},
			username:'',
			cx:'',
			//xiabiaoduan2
		};
	},
	created() {
		if (!Session.get('userInfo')) return false;
		this.userInfo = Session.get('userInfo');
		this.username=localStorage.getItem("username");
		this.cx=localStorage.getItem("cx");
		let id = this.$route.params.id;
		//xiabiaoduan3
		this.getUserInfo(id);
	},
	computed: {
		headers(){
			return {"token":Session.get("token")}
		},
	},
	methods:{
		getUserInfo(id){
			yingshishipinDetail(id).then(res=>{
				if(res.code == '0'){
					this.yingshishipin = res.data
					this.editForm.shipinbianhao = this.yingshishipin.shipinbianhao;
					this.editForm.shipinmingcheng = this.yingshishipin.shipinmingcheng;
					this.editForm.leibie = this.yingshishipin.leibie;
				
					this.editForm.yonghuming= this.userInfo.yonghuming;
					
					this.editForm.xingming= this.userInfo.xingming;
				
				}
			})
		},
		
		//qixuzhijixsuan3
		//xia2sui1
		// 编辑、增加页面保存方法
		submitForm(editData) {
			
			this.$refs[editData].validate(valid => {
				if (valid) {
					if(this.editForm.id){
						
					}else {
						yingpingfankuiSave(this.editForm).then(res => {
							if (res.code == '0') {
								
								this.$message({
									type: 'success',
									message: '添加成功！'
								})
							} else {
								this.$message({
									type: 'info',
									message: res.msg
								})
							}
						}).catch(err => {
							if(err){
								this.$message.error(err)
							}else {
								this.$message.error('操作失败，请稍后再试！')
							}
						})
					}
				} else {
					return false
				}
			})
		},
		
		//youscwexnjiaxn
		//xiabiaoduan4
	}
};
</script>

<style scoped lang="scss">
	@import './index.scss';
</style>
